<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

<head>
    <meta charset="utf-8"/>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" type="text/css">
    <link th:href="@{/plugin/jquery-confirm/jquery-confirm.css}" rel="stylesheet"/>
    <link th:href="@{/css/style_index.css}" rel="stylesheet" type="text/css"/>
    <title>幼儿园管理系统</title>
</head>

<body>
<div id="wrap">
    <!--顶部导航-->
    <div class="topnav clear">
        <div class="lt-topnav clear">
            <ul class="topmenu clear" style="position: absolute;left: 350px">
                <li id="topmenu_click" class="index">
                    <a onclick="getPage('/home')">
                        <img th:src="@{/images/top_icon04_pre.png}"/>
                        <span>首页</span>
                    </a>
                </li>
                <li class="classInfo">
                    <a onclick="getPage('/class/toClassPage')">
                        <img th:src="@{/images/top_icon03_pre.png}"/>
                        <span>班级管理</span>
                    </a>
                </li>
                <li class="studentInfo">
                    <a onclick="getPage('/student/toStudentPage')">
                        <img th:src="@{/images/top_icon02_pre.png}"/>
                        <span>学生管理</span>
                    </a>
                </li>
                <!--<shiro:hasAnyRoles name="teacher">-->
                    <!--<li class="myInfo">-->
                        <!--<a onclick="getPage('')">-->
                            <!--<img th:src="@{/images/top_icon01_pre.png}"/>-->
                            <!--<span>我的信息</span>-->
                        <!--</a>-->
                    <!--</li>-->
                <!--</shiro:hasAnyRoles>-->

                <shiro:hasAnyRoles name="teacher,admin">
                    <li class="studentInput">
                        <a onclick="getPage('/studentInput/studentInput')">
                            <img th:src="@{/images/top_icon05_pre.png}"/>
                            <span>导入学生</span>
                        </a>
                    </li>
                </shiro:hasAnyRoles>

                <li class="teacherInfo">
                    <a onclick="getPage('/teacher/toTeacherPage')">
                        <img th:src="@{/images/top_icon07_pre.png}"/>
                        <span>教师管理</span>
                    </a>
                </li>
                <shiro:hasAnyRoles name="admin">
                    <li class="systemManager">
                        <a onclick="getPage('/toSystemManager')">
                            <img th:src="@{/images/top_icon06_pre.png}"/>
                            <span>系统管理</span>
                        </a>
                    </li>
                </shiro:hasAnyRoles>
            </ul>
        </div>
        <ul class="rt-topnav clear">

            <li class="admin-li">
                <a href="javascript:void(0);">
                    <img th:src="@{/images/top_icon08.png}"/>
                    <span th:text="${session.user.getRealName()}"></span>
                </a>
                <div class="top-personset">
                    <ul>
                        <li>
                            <a onclick="toUserInfo()">
                                <i class="glyphicon glyphicon-user"></i> 基本信息
                            </a>
                        </li>
                        <li>
                            <a onclick="toUpdatePassword();">
                                <i class="glyphicon glyphicon-cog"></i> 修改密码
                            </a>
                        <li>
                            <a href="/logout">
                                <i class="glyphicon glyphicon-off"></i> 退出系统
                            </a>
                        </li>
                    </ul>
                </div>
            </li>
        </ul>
    </div>
    <div id="iframebox" style="position: absolute;top: 60px">
        <iframe id="contentiframe" style="width:100%;height:100%;" frameborder="0"></iframe>
    </div>

    <!--footer-->
    <div class="footer">
        版权所有&copy;滁州学院-计算机与信息工程学院-物联网152-马继斌
    </div>
</div>
</body>
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/plugin/jquery-confirm/jquery-confirm.js}"></script>
<script type="text/javascript" th:src="@{/plugin/jquery-confirm/jquery-confirm_cn.js}"></script>
<script th:inline="javascript">
    $(function () {
        var url = [[${url}]];
        url == null ? url = "/home" : displayTargetMenu(url);
        $("#contentiframe").attr('src', url);

    });

    /**
     * 弹出用户详细信息页面
     */
    function toUserInfo() {
        var url = '/getUserInfo';
        openWindow("基本信息", ['420px', '320px'], url);
    }

    /**
     * 弹出修改密码页面
     */
    function toUpdatePassword() {
        var url = '/toUpdatePassword';
        openWindow("修改密码", ['400px', '300px'], url);
    }

    /**
     * 切换导航栏焦点方法
     * @param url
     */
    function displayTargetMenu(url) {
        $("#topmenu_click").removeAttr("id");
        var target = "index";
        switch (url) {
            case "/classInfo/modulePage":
                target = "classInfo";
                break;
            case "/studentInfo/modulePage":
                target = "studentInfo";
                break;
            case "/myInfo/getPage":
                target = "myInfo";
                break;
            case "/division/modulePage":
                target = "division";
                break;
            case "/teacherInfo/policeMap":
                target = "teacherInfo";
                break;
            case "/standardSystem/modulePage":
                target = "standardSystem";
                break;
            case "/systemManager/modulePage":
                target = "systemManager";
                break;
        }
        $("." + target).attr("id", "topmenu_click");
    }

    $(".topmenu li").click(function () {
        $("#topmenu_click").removeAttr("id");
        $(this).attr("id", "topmenu_click");
    });
    $(".nextnav a").click(function () {
        $("#nextnav_click").removeAttr("id");
        $(this).attr("id", "nextnav_click");
    });


    //iframe切換
    function getPage(req) {
        $("#contentiframe").attr('src', req);
    }

    //弹窗
    function openWindow(title, area, url, callback) {
        layer.open({
            type: 2,
            title: "<a class='layer_title'>" + title + "</a>",
            area: area,
            fixed: false,
            resize: false,
            contentType: 'application/x-www-form-urlencoded',
            content: url,
            success: function (currentDom, index) {
                if (callback == null || typeof(callback) == "undefined") {
                    return;
                }
                callback();
            }
        });
    }

    function closeWindow(msg) {
        layer.close(layer.index);
        if(msg != null && msg != ""){
            layer.msg(msg);
        }

    }

    /**
     * 判断字符串是否为空
     * @param s
     * @returns {boolean}
     */
    function isEmpty(s) {
        if (typeof s == "undefined" || s == null || s == "") {
            return true;
        } else {
            return false;
        }
    }

    function successClose(msg) {
        layer.close(layer.index);
        layer.msg(msg);
    }

    /**
     * class页面获取班级信息方法
     * @param limit
     * @param page
     */
    function searchClass(limit, page) {
        layer.close(layer.index);
        document.getElementById("contentiframe").contentWindow.searchClass(limit, page);

    }


    /**
     * 系统页面获取用户信息方法
     * @param limit
     * @param page
     */
    function searchUser(limit, page) {
        layer.close(layer.index);
        document.getElementById("contentiframe").contentWindow.searchUser(limit, page);

    }
    /**
     * Teacher页面获取教师信息方法
     * @param limit
     * @param page
     */
    function searchTeacher(limit, page) {
        layer.close(layer.index);
        document.getElementById("contentiframe").contentWindow.searchTeacher(limit, page);

    }
    /**
     * student页面获取学生信息方法
     * @param limit
     * @param page
     */
    function searchStudent(limit, page) {
        layer.close(layer.index);
        document.getElementById("contentiframe").contentWindow.searchStudent(limit, page);
    }

    //home页面查询资讯或意见方法
    function getAdviceOrMassage() {
        layer.close(layer.index);
        document.getElementById("contentiframe").contentWindow.getAdviceOrMassage(limit, page);
    }

    //导入学生界面查询批次方法
    function queryData(limit, page) {
        layer.close(layer.index);
        document.getElementById("contentiframe").contentWindow.queryData(limit, page);
    }

    /**
     * 下拉选择框初始值
     *
     */
    function selectNumber(options,select){
        for (var j = 1; j < options.length; j++) {
            if ($(options[j]).val() == select) {
                $(options[j]).attr("selected", "selected");
            }
        }
    }

</script>

</html>
